<?php
if (!defined('IN_XLP')) {
    exit('Access Denied');
}
$Document = array(
    'pageid' => 'access-edit', //页面标示
    'pagename' => '编辑节点', //当前页面名称
    'mycss' => array(), //加载的css样式表
    'myjs' => array(), //加载的js脚本
	'footerjs'=>array(),
    'head' => true, //加载头部文件
);
include getTpl('header', 'public');
?>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public');?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public');?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<section id="content">
  <section class="main padder">
    <div class="clearfix">
      <h4><i class="fa fa-edit"></i><?php echo trim($Document['pagename'],'_');?></h4>
    </div>
    <div class="row">
      <div class="col-sm-12">
        <section class="panel">
          <div class="panel-body">
            <form class="form-horizontal" method="post" id="Form1">
              <div class="form-group">
                <label class="col-sm-1 control-label">节点分组名称</label>
                <div class="col-sm-3">
                  <input type="text" name="c_group" id="c_group" placeholder="" class="form-control" value="<?php echo $rs['c_group'];?>" />
                  <span class="help-block">长度为2-30个字符</span></div>
              </div>
              <div class="form-group">
                <label class="col-sm-1 control-label">节点分组代码</label>
                <div class="col-sm-3">
                  <input type="text" name="n_group" id="n_group" placeholder="" class="form-control" value="<?php echo $rs['n_group'];?>" />
                  <span class="help-block">长度为2-30个字符</span></div>
              </div>
              <div class="form-group">
                <label class="col-sm-1 control-label">节点控制器名称</label>
                <div class="col-sm-3">
                  <input type="text" name="c_action" id="c_action" placeholder="" class="form-control" value="<?php echo $rs['c_action'];?>" />
                  <span class="help-block">长度为2-30个字符</span></div>
              </div>
              <div class="form-group">
                <label class="col-sm-1 control-label">节点控制器代码</label>
                <div class="col-sm-3">
                  <input type="text" name="n_action" id="n_action" placeholder="" class="form-control" value="<?php echo $rs['n_action'];?>" />
                  <span class="help-block">长度为2-30个字符</span></div>
              </div>
              <div class="form-group">
                <label class="col-sm-1 control-label">节点模块名称</label>
                <div class="col-sm-3">
                  <input type="text" name="c_model" id="c_model" placeholder="" class="form-control" value="<?php echo $rs['c_model'];?>" />
                  <span class="help-block">长度为2-30个字符</span></div>
              </div>
              <div class="form-group">
                <label class="col-sm-1 control-label">节点模块代码</label>
                <div class="col-sm-3">
                  <input type="text" name="n_model" id="n_model" placeholder="" class="form-control" value="<?php echo $rs['n_model'];?>" />
                  <span class="help-block">长度为2-30个字符</span></div>
              </div>

              <div class="form-group">
                <div class="col-sm-9 col-lg-offset-1">
                  <div class="col-sm-1">
                  <input name="id" type="hidden" value="<?php echo $rs['nid'];?>" />
                    <button type="submit" id="sub-ok" data-loading-text="正在提交..." class="btn btn-primary">保存</button>
                  </div>
                  <div class="col-md-offset-2">
                    <button id="goback" type="button" class="btn btn-white">取消</button>
                  </div>
                </div>
              </div>
            </form>
          </div>
        </section>
      </div>
    </div>
  </section>
</section>
<!--主体 结束--> 
<script>
$(function(){
	$('#Form1').submit(function(){
		var c_group=$.trim($("#c_group").val());
		var n_group=$.trim($("#n_group").val());
		var c_action=$.trim($("#c_action").val());
		var n_action=$.trim($("#n_action").val());
		var c_model=$.trim($("#c_model").val());
		var n_model=$.trim($("#n_model").val());
		if (!c_group||!n_group){
			Msg.error('分组名称不能为空');
			resetSubmit("#sub-ok",'保存');
			return false;
		}
		if (!c_action||!n_action){
			Msg.error('控制器名称不能为空');
			resetSubmit("#sub-ok",'保存');
			return false;
		}
		if (!c_model||!n_model){
			Msg.error('模块名称不能为空');
			resetSubmit("#sub-ok",'保存');
			return false;
		}
		Msg.loading();
		  $.post('<?php echo U('access/save');?>',$(this).serialize(),function(result){
			  Msg.hide();
			  resetSubmit("#sub-ok",'保存');
			  if (result.status==1){
				Msg.ok('编辑成功',function(){
					document.location='<?php echo U('access/index');?>';
				},1000);  
			}else{
				Msg.error(result.info);
			}
		  },'json');
		return false;
	})
	$("#goback").click(function(){
		document.location='<?php echo U('access/index');?>';
	})
})
</script>
<?php
include getTpl('footer', 'public');
?>